#include "widget.h"
#include "ui_widget.h"
#include <QColorDialog>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_color_clicked()
{
    color = QColorDialog::getColor(color,this);
    if(color.isValid()){
        ui->textEdit->setTextColor(color);
        ui->textEdit->setFocus();
    }
}

void Widget::on_comboBox_frontsize_currentIndexChanged()
{
    QString selectedSize = ui->comboBox_frontsize->currentText(); // 获取用户选择的字号
    bool conversionOK = false;
    int fontSize = selectedSize.toInt(&conversionOK);

    if (conversionOK) {
        QFont font = ui->textEdit->font();
        font.setPointSize(fontSize);
        ui->textEdit->setFont(font);
    }
    ui->textEdit->setFocus();
}

void Widget::on_comboBox_front_currentIndexChanged()
{
    QString selectedFont = ui->comboBox_front->currentText(); // 获取用户选择的字体
    QFont font = ui->textEdit->font();
    font.setFamily(selectedFont);
    ui->textEdit->setFont(font);
    ui->textEdit->setFocus();
}
